package net.jxvtc;

import net.jxvtc.ioc.ClientService;
import net.jxvtc.ioc.ClientServiceImpl;
import net.jxvtc.ioc.HappyComponent;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class HappyComponentTest {

     ClassPathXmlApplicationContext context;

    @BeforeEach
    public  void init(){
         context=new ClassPathXmlApplicationContext("/spring-bean-01.xml");
    }

    @Test
    public void testGetHappyComponent(){

        HappyComponent happyComponent = context.getBean("happyComponent", HappyComponent.class);
        happyComponent.doWork();
    }


    @Test
    public void testCreateClientService(){
        ClientService clientServic = context.getBean("clientService", ClientService.class);
        clientServic.sayHello();
    }

    @Test
    public void testCreateClientServiceImpl(){
        ClientServiceImpl clientServiceImpl = context.getBean("clientServiceImpl", ClientServiceImpl.class);
        clientServiceImpl.displayInfo();
    }
}
